<?php
	$suggestion_list = $this->suggestion_list;
	$product_list = $this->product_list;
	
	echo "<form method = 'Post' name = 'main_form'>";
	echo  $this->formHidden('mode','delete');
	echo  $this->formHidden('product_id');
	echo  $this->formHidden('type');	
	echo "</form>";
?>

<div class="col-md-12">
	<div class="col-md-12">		
		<div class="col-md-12">
			QUẢN LÝ GỢI Ý CHO NGƯỜI DÙNG
		</div>
		<div class="col-md-12">
			<a id = "add-suggestion" style="background: #359AFF;
						padding: 15px 25px;
						display: inline-block;
						margin-top: 10px;
						color: #fff;
						text-transform: uppercase;
						font-size: 16px;
						text-decoration: none;
			">
				Thêm sản phẩm
			</a>
			<br />
			<br />
			<span style = "color : #ccc">Thiết lập game random xuất hiện ở cuối trang chi tiết</span>
			<br />
			<br />
		</div>
	</div>
</div>
<hr>
<br />
<br />
<div class="col-md-12">
	<?php foreach($suggestion_list as $suggestion) :?>		
		<div class="col-md-3">
			<div class="col-md-12">
				<?php echo ($suggestion["product_type"] == 1)?"<b>Game : </b>":"<b>Ứng dụng : </b>"?>
				<br />
				<br />
				<?php echo "<b>" . $suggestion["product"] . "</b>"?>
				<br />
				<?php echo "<span style = 'color:#ccc'>" . $suggestion["developer"] . "</span>"?>
				<br />
				<br />
			</div>
			<div class="col-md-6">
			<img src = "<?php echo $suggestion["icon"] ?>" width = 100% />
			</div>
			<div class="col-md-3">
			<button onclick = "delete_suggestion(<?php echo $suggestion["id"] ?>)" class = "btn btn-default">Xóa</button>
			</div>				
		</div>
	<?php endforeach; ?>	
</div>
<div class = "clearfix"></div>
<div id='add-suggestion-form' title='Sửa' style = 'display:none'>
	<form class = 'form-horizontal' method = 'post' role = 'form' style = 'width : 90%'>
	<div class='form-group'>
	<label class='col-md-3 control-label'>Sản phẩm</label>
	<div class='col-md-8'>
	<?php echo $this->formSelect('edit_product_id',0,array('class'	=> 'form-control'),$product_list); ?>
	</div>
	</div>		
	</form>
	</div>
<script type="text/javascript">
<!--
$(document).ready(function(){
	$('#add-suggestion').click(function(){				
		$('#mode').val('add');				
		jQuery( "#add-suggestion-form" ).dialog({
			resizable: true,
			height:250,
			width: 500,
			modal: true,
			buttons:[{
				text: 'Thêm',
				click : function() {
					$('#product_id').val($('#edit_product_id').val());	
					submit_form();
					}
				},{
				text: 'Hủy bỏ',
				click : function() { $(this).dialog("close"); }
			}]
		});
	});	
	$('#add-random-suggestion').click(function(){		
		$('#type').val('2');				
		$('#mode').val('add');				
		jQuery( "#add-suggestion-form" ).dialog({
			resizable: true,
			height:250,
			width: 500,
			modal: true,
			buttons:[{
				text: 'Thêm',
				click : function() {
					$('#product_id').val($('#edit_product_id').val());	
					submit_form();
					}
				},{
				text: 'Hủy bỏ',
				click : function() { $(this).dialog("close"); }
			}]
		});
	});	
});
function submit_form(){
	var frm = document.main_form;	
	frm.submit();
}
function delete_suggestion(id){
	$('#mode').val('delete');
	$('#product_id').val(id);
	submit_form();
}
//-->
</script>